package cc.mrbird.common.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class MD5Utils {
	private static final String SALT = "admin";

	private static final String ALGORITH_NAME = "md5";

	private static final int HASH_ITERATIONS = 2;

	public static String encrypt(String pswd) {
		String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(SALT), HASH_ITERATIONS).toHex();
		return newPassword;
	}

	public static String encrypt(String username, String pswd) {
		String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(username.toLowerCase() + SALT),
				HASH_ITERATIONS).toHex();
		return newPassword;
	}
	public static void main(String[] args) {
		
		System.out.println(MD5Utils.encrypt("admin", "123456"));
		System.out.println(MD5Utils.encrypt("郑州东", "123456"));
		System.out.println(MD5Utils.encrypt("洛阳", "123456"));
		System.out.println(MD5Utils.encrypt("开封", "123456"));
		System.out.println(MD5Utils.encrypt("平顶山", "123456"));
		System.out.println(MD5Utils.encrypt("新乡", "123456"));
		System.out.println(MD5Utils.encrypt("焦作济源", "123456"));
		System.out.println(MD5Utils.encrypt("安阳鹤壁", "123456"));
		System.out.println(MD5Utils.encrypt("濮阳", "123456"));
		System.out.println(MD5Utils.encrypt("三门峡", "123456"));
		System.out.println(MD5Utils.encrypt("许昌", "123456"));
		System.out.println(MD5Utils.encrypt("商丘东", "123456"));
		System.out.println(MD5Utils.encrypt("商丘西", "123456"));
		System.out.println(MD5Utils.encrypt("周口东", "123456"));
		System.out.println(MD5Utils.encrypt("周口西", "123456"));
		System.out.println(MD5Utils.encrypt("驻马店", "123456"));
		System.out.println(MD5Utils.encrypt("信阳", "123456"));
		System.out.println(MD5Utils.encrypt("南阳东", "123456"));
		System.out.println(MD5Utils.encrypt("南阳西", "123456"));
		System.out.println(MD5Utils.encrypt("管理员", "123456"));
		System.out.println(MD5Utils.encrypt("漯河郑州西", "123456"));
		System.out.println(MD5Utils.encrypt("漯河郑州西2", "123456"));
		System.out.println(MD5Utils.encrypt("漯河郑州西3", "123456"));
	}

}
